<?php
/********************************************************************************
 * File: rss.php
 * Desc: Returns RSS v0.92 feed for last 20 flickr photos.
 * 
 * Change   Date        By          Description
 * 1        05/13/2007  mcarruth    Created
 ********************************************************************************/
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<rss version='0.92'>\n";

require_once("inc/config.inc");

$photos = $f->photos_search(array("user_id"=>$config_flickrUserId, "extras"=>"date_taken", "per_page"=>"20", "page"=>"1"));
$userInfo = $f->people_getInfo($config_flickrUserId);

//
// Boiler-plate RSS info
//
echo "   <channel>\n";
echo "      <title>$config_siteTitle</title>\n";
echo "      <link>$config_siteUrl</link>\n";
echo "      <description>$config_siteDescription</description>\n";
echo "		<pubDate>" . date(DATE_RFC2822) . "</pubDate>\n";
echo "      <lastBuildDate>" . date(DATE_RFC2822) . "</lastBuildDate>\n";
echo "      <image>\n";
echo "         <url>http://farm" . $userInfo['iconfarm'] . ".static.flickr.com/" . $userInfo['iconserver']. "/buddyicons/" . $userInfo['nsid'] . ".jpg</url>\n";
echo "         <title>$config_siteTitle</title>\n";
echo "         <link>$config_siteUrl</link>\n";
echo "      </image>\n";

//
// Generate items for the last 20 photos
//
foreach ($photos['photo'] as $photo) {
$photoInfo = $f->photos_getInfo($photo['id']);
$date = getdate(strtotime($photoInfo['dates']['taken']));
echo "      <item>\n";
echo "         <title>" . $photo['title'] . "</title>\n";
echo "         <link>index.php?id=" . $photo['id'] . "</link>\n";
echo "         <description>\n";
echo "            &lt;a href=&quot;index.php?id=" . $photo['id'] . "&quot;&gt;";
echo "               &lt;img style=&quot;border:0;&quot; src=&quot;" . $f->buildPhotoURL($photo) . "&quot;/&gt;";
echo "            &lt;/a&gt;";
echo "            &lt;p&gt;" . $photoInfo['description'] . "&lt;/p&gt;";
echo "            &lt;p&gt;" . $date[month] . " " . $date[mday] . ", " . $date[year] . "&lt;/p&gt;";
echo "         </description>\n";
echo "      </item>\n";
}

echo "   </channel>\n";
echo "</rss>\n";

?>